#include "common.hpp"

int main()
{
    bool b = creatnamedpipe(NAMED_PIPE);
    assert(b == true);
    std::cout << "wait read" << std::endl;
    int wfd = open(NAMED_PIPE, O_WRONLY);
    std::cout << "wait finish" << std::endl;
    if (wfd < 0)
    {
        exit(0);
    }

    // 写入信息
    while (1)
    {
        char buffer[1024];
        std::cout << "send message: ";
        fgets(buffer, sizeof(buffer) - 1, stdin);
        ssize_t n = write(wfd, buffer, strlen(buffer));
        assert(n == strlen(buffer));
    }

    close(wfd);
    deletenamedpipe(NAMED_PIPE);
}